package cn.xz.gobang.dialog

import android.os.Handler
import android.view.Gravity
import android.widget.TextView
import cn.xz.gobang.R
import cn.xz.gobang.base.BaseDialogRxFragment
import cn.xz.gobang.bean.CommonLib

/**
 * 开始游戏弹窗
 * */
class StartPkDialog: BaseDialogRxFragment() {

    private var tvBlack: TextView? = null
    private var tvWhite: TextView? = null


    companion object {
        fun newInstance(
        ): StartPkDialog {
            return StartPkDialog()
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.item_start_px_dialog
    }

    override fun configDialog() {
        this.setDialogSize(gravity = Gravity.CENTER,width = 300, height = 300)
    }

    override fun initViews() {

        dialog?.let {
            tvBlack = it.findViewById(R.id.tv_black)
            tvWhite = it.findViewById(R.id.tv_white)
        }

        //点击外部不隐藏
        dialog?.setCancelable(false)
        dialog?.setCanceledOnTouchOutside(false)
        //视图相关
        initUI()
    }

    private fun initUI(){
        tvBlack?.text = "000"
        tvWhite?.text = CommonLib.UserIP
        //三秒弹窗消失
        Handler().postDelayed({
            dismiss()
        }, 3 * 1000)
    }

}